﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="UserImageRatings.aspx.cs" Inherits="WebApplicationRating.Views.UserImageRatings" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="cc1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .style1
        {
            font-size: large;
        }
        .style2
        {
            width: 45px;
        }
        .style4
        {
            font-size: large;
            width: 78px;
        }
        .style5
        {
            font-size: small;
        }
        .style6
        {
            width: 45px;
            font-size: small;
        }
        .style7
        {
            width: 36px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:Button ID="btnBack" runat="server" style="margin-left: 350px" onclick="btnBack_Click" Text="Back" />&nbsp;&nbsp;
 <table width="0%" border="0" class="basic11pt">
 <tr>
 <td class="style2">
     <asp:SqlDataSource ID="SqlDataSourceRatings0" runat="server" 
        ConnectionString="<%$ ConnectionStrings:imageConnectionString %>"          
        SelectCommand="SELECT Image.name AS Name, COUNT(*) AS rtgcnt, AVG(UserImageRating.rating) AS avgRating FROM Image INNER JOIN UserImage ON UserImage.imageid = Image.imageid AND Image.imageid = @imageid LEFT OUTER JOIN UserImageRating ON UserImageRating.imageid = Image.imageid AND UserImageRating.imageid = @imageid AND UserImageRating.imageid = UserImage.imageid AND UserImage.imageid = Image.imageid GROUP BY Image.name" 
        ViewStateMode="Enabled">
        <SelectParameters>
            <asp:ControlParameter ControlID="tbMGID" Name="imageid" PropertyName="Text" />
         </SelectParameters>
     </asp:SqlDataSource>
        &nbsp;</td>
  <td colspan="2"><br />
&nbsp;
        <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
            DataSourceID="SqlDataSourceRatings0" 
            style="margin-left: 251px" Caption="Rating Information">
            <Columns>
                <asp:BoundField DataField="Name" HeaderText="Name" 
                    SortExpression="Name" />
                <asp:BoundField DataField="rtgcnt" 
                    HeaderText="Count" ReadOnly="True" SortExpression="rtgcnt" />
                <asp:BoundField DataField="avgRating" DataFormatString="{0:n2}" 
                    HeaderText="Overall" ReadOnly="True" SortExpression="avgRating" />
            </Columns>
        </asp:GridView>
    </td>
 </tr>
 <tr>
  <td class="style2">&nbsp;</td>
  <td class="style1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CONTRIBUTE YOURS!</td>
  <td class="style4">&nbsp;</td>
  <td class="style7">    
      &nbsp;</td></tr>
 <tr>
  <td class="style6">&nbsp;</td>
  <td class="style5">Set Your Choice - <asp:Label ID="lblMessage" runat="server" Text=" " style="margin-left: 30px" Font-Bold="true" foreColor="Orange" ></asp:Label></td>
  <td class="style4">&nbsp;</td>
  <td class="style7">    
      &nbsp;</td>
 </tr>
 <tr>
  <td class="style6">&nbsp;</td>
  <td class="style5">poor</td>
  </tr>
 <tr>
  <td class="style2">&nbsp;</td>
  <td class="style1">
         <asp:RadioButtonList ID="rblRating" runat="server" style="margin-left: 4px" 
             Width="287px">
           <asp:ListItem value="1" selected="false" Text='<img src="../Styles/Images/starhot1.gif" alt=""> (One) '  />
           <asp:ListItem value="2" selected="false" Text='<img src="../Styles/Images/starhot2.gif" alt=""> (Two) '  />
           <asp:ListItem value="3" selected="false" Text='<img src="../Styles/Images/starhot3.gif" alt=""> (Three) '  />
           <asp:ListItem value="4" selected="false" Text='<img src="../Styles/Images/starhot4.gif" alt=""> (Four) '  />
           <asp:ListItem value="5" selected="false" Text='<img src="../Styles/Images/starhot5.gif" alt=""> (Five) '  />
         </asp:RadioButtonList>
         </td>
  <td class="style4">&nbsp;</td>
  <td class="style7">    
      &nbsp;</td>
 </tr>
 <tr>
  <td class="style6">&nbsp;</td>
  <td class="style5">great</td>
  <td class="style4">
      <asp:Button ID="btnSave" runat="server" onclick="btnSave_Click" Text="Rate It!" 
        style="margin-left: 4px" Width="88px" Height="24px" /></td>
  <td class="style7">    
      &nbsp;</td>
 </tr>
 </table>
 <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
     <div class="ContentHead">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         </div>
<table>
<tr>
<td>
      <asp:GridView ID="GridView1" runat="server" 
        AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
        EmptyDataText="There are no prior session ratings to display." Height="68px" 
        PageSize="1" style="margin-left: 37px; margin-top: 18px" Width="28px">
        <Columns>
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
            <asp:BoundField DataField="YourPrevious" HeaderText="YourPrevious" 
                SortExpression="YourPrevious" />
        </Columns>
    </asp:GridView>   
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:imageConnectionString2 %>" 
        ProviderName="<%$ ConnectionStrings:imageConnectionString2.ProviderName %>"         
        
          
          SelectCommand="SELECT Image.name AS Name, UserImageRating.rating AS YourPrevious FROM Image INNER JOIN UserImage
ON UserImage.imageid = Image.imageid AND UserImage.imageid = @imageid
LEFT OUTER JOIN UserImageRating ON UserImageRating.imageid = Image.imageid AND UserImageRating.imageid = @imageid AND UserImageRating.userid = @userid">
        <SelectParameters>
            <asp:ControlParameter ControlID="tbMGID" Name="imageid" PropertyName="Text" />
            <asp:ControlParameter ControlID="tbPUSR" Name="userid" PropertyName="Text" />
        </SelectParameters>
    </asp:SqlDataSource>
    &nbsp;<asp:SqlDataSource ID="SqlDataSourceRatings" runat="server" 
        ConnectionString="<%$ ConnectionStrings:imageConnectionString %>"  
        SelectCommand="SELECT NULL AS ratingid, NULL AS description UNION SELECT ratingid, description FROM Rating">
    </asp:SqlDataSource>
</td>
<td>
<asp:Label ID="lblMessageM" runat="server" Text=" " style="margin-left: 30px"></asp:Label>
</td>
<td>
<asp:TextBox ID="tbMGID" runat="server" Width="50px" Enabled="false" style="margin-left: 30px;" ></asp:TextBox>
</td>
<td>
<asp:Label ID="lblMessageU" runat="server" Text=" " style="margin-left: 30px"></asp:Label>
</td>
<td>
<asp:TextBox ID="tbPUSR" runat="server" Width="50px" Enabled="false" style="margin-left: 30px"></asp:TextBox>
</td>
</tr>
</table>
</asp:Content>


